package com.peza.bikelog.business.service.impl;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import com.peza.bikelog.business.service.PolarService;
import com.peza.bikelog.common.domain.polar.HrmData;

public class PolarServiceImpl implements PolarService{
	
	public HrmData getPolarData(File file){

		StringBuffer buffer = new StringBuffer();
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			String line = null;
			while ((line = reader.readLine()) != null) {
				buffer.append(line+"\n");
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				reader.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		HrmData hrmData = new HrmData(buffer.toString());
		return hrmData;
		
	}

}
